import request from "@/utils/request";

const apiPrefix = "/admin/system/sysRole";

export function getPageList(page, limit, searchObj) {
  return request({
    url: `${apiPrefix}/${page}/${limit}`,
    method: "get",
    params: searchObj,
  });
}

export function deleteById(id) {
  return request({
    url: `${apiPrefix}/remove/${id}`,
    method: "delete",
  });
}

export function add(role) {
  return request({
    url: `${apiPrefix}/save`,
    method: "post",
    data: role,
  });
}

export function updateById(role) {
  return request({
    url: `${apiPrefix}/update`,
    method: "post",
    data: role,
  });
}

export function batchDelete(ids) {
  return request({
    url: `${apiPrefix}/batchRemove`,
    method: "delete",
    data: ids,
  });
}

export function queryRoleById(id) {
  return request({
    url: `${apiPrefix}/toAssign/${id}`,
    method: "get",
  });
}

export function doAssignRole(assignRoleVo) {
  return request({
    url: `${apiPrefix}/doAssign`,
    method: "post",
    data: assignRoleVo,
  });
}

export function findMenuByRoleId(roleId) {
  return request({
    url: `${apiPrefix}/queryMenu/${roleId}`,
    method: "get",
  });
}

export async function authMenu(vo) {
  return request({
    url: `${apiPrefix}/authMenu`,
    method: "post",
    data: vo,
  });
}
